package cn.net.xyan.pay.core.entity

import cn.net.xyan.kotlin.NoArg
import java.io.Serializable
import java.util.*
import javax.persistence.*

/**
 * Created by zarra on 2017/3/22.
 */

@Entity
@Table(name = "cards")
@NoArg
data class MedicalCard(
         val cardNO: String ,
         @Id
         val cardID: String = cardNO
) {
    var cardType: Int = -1

    var realName: String = "unknown"

    @Temporal(TemporalType.TIMESTAMP)
    var birthday: Date = Date()

    var phone: String = ""

    var address: String = ""
}


@NoArg
data class VendorUserInfoPK(val vendor:String,val vendorNo:String):Serializable{

}

@Entity
@Table(name = "vendorUserInfo")
@IdClass(VendorUserInfoPK::class)
@NoArg
data class VendorUserInfo(@Id val vendor:String,@Id val vendorNo:String){

    @ManyToOne
    @JoinColumn(name = "patientUser")
    var patientUser:PatientUser? = null

    var realName:String? = null
    var address:String? = null
    var phone:String? = null

    var gender:String? = null
}

@Entity
@Table(name = "patientUser")
@NoArg
data class PatientUser(@Id val userName:String){
    var realName:String = "unknown"
    var phone:String    = "unknown"
    var address:String  = "unknown"

    @OneToMany(mappedBy = "patientUser")
    var userInfoList:MutableList<VendorUserInfo> = LinkedList()
}

